package com.cy.controller.web;

import com.cy.pojo.Merch;
import com.cy.service.MerchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;


import java.util.List;

/**
 * 后台操作
 * @author qyq
 * @create 2021-03-02-9:42
 */
@Controller
public class ItemController {
    @Autowired
    private MerchService merchService;

    @RequestMapping("/index/merch")
    public String findAll(Model model) {
        List<Merch> merchs = merchService.findMerchs();
        model.addAttribute("merchs",merchs);
        return "index";
    }

    @RequestMapping("/save")
    public String saveMerch(Merch merch) {
        merchService.saveMerch(merch);
        return "index";
    }
}
